package com.yijiaganxi.product.api.product;


import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.yijiaganxi.common.entity.product.YjgxProduct;
import org.yijiaganxi.common.res.R;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.yijiaganxi.common.GlobalConstants;
import com.yijiaganxi.product.service.product.YjgxProductService;

import javax.validation.constraints.NotBlank;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;

/**
 * <p>
 * 商品管理 前端控制器
 * </p>
 *
 * @author zhangguowei123
 * @since 2020-08-29
 */
@Validated
@RestController
@RequestMapping("/product/yjgxProduct/"+GlobalConstants.WECHAT_FLAG)
public class YjgxProductApi {

	@Autowired
	public YjgxProductService  productService;
	
	
	/**
	 * 根据分类id查询商品分页数据
	 * @param categoryId
	 * @param cureentPage
	 * @param size
	 * @return
	 */
	@GetMapping("getProductListPageByCategoryId")
	public R getProductListPageByCatetoryId(@NotBlank(message = "商品分类id必填") String categoryId,
			@NotBlank(message = "cureentPage不能为空") Integer cureentPage,
			@NotBlank(message = "size不能为空") Integer size) {
		Page<YjgxProduct> selectPage = productService.selectPage(new Page<YjgxProduct>(cureentPage, size),
				new EntityWrapper<YjgxProduct>()
				.eq("categoryId", categoryId));
		return R.ok().put("data", selectPage);
	}
	
	
	
	
}

